package com.dzzw.Servlet.EmployeeServlet;

import com.dzzw.Dao.EmployeeDao;
import com.dzzw.Model.Employee;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

@WebServlet("/View/EmployeeModifyServlet")
public class EmployeeModifyServlet extends HttpServlet {
    private static final long serialVersionUID = 1L;
    private final EmployeeDao employeeDao = new EmployeeDao();
    public EmployeeModifyServlet(){
        super();
    }
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        doGet(request,response);
    }

    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        request.setCharacterEncoding("utf-8");
        response.setContentType("text/html;charset=utf-8");
        String employee_name = request.getParameter("employee_name");
        String employee_actnumber = request.getParameter("employee_actnumber");
        String employee_password = request.getParameter("employee_password");
        int leader_id = Integer.parseInt(request.getParameter("leader_id"));
        int department_id = Integer.parseInt(request.getParameter("department_id"));
        Employee employee = new Employee();
        employee.setEmployee_actnumber(employee_name);
        employee.setEmployee_actnumber(employee_actnumber);
        employee.setEmployee_password(employee_password);
        employee.setLeader_id(leader_id);
        employee.setDepartment_id(department_id);
        employeeDao.EmployeeAdd(employee);
        System.out.println("公务员修改信息成功！");
        response.sendRedirect("/View/");
    }
}
